package me.baicai.weixin.identity.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import me.baicai.weixin.application.Result;
import me.baicai.weixin.identity.service.ManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Api(tags = "维护人员操作：维护人员操作")
@RestController
public class ManageController
{

    @Autowired
    private ManageService manageService;

    @ApiOperation("维护人员的店铺")
    @PostMapping("/manage/manageShop")
    public Result manageShop(@RequestHeader("openid") String openid,
                             @RequestParam("page") Integer page,
                             @RequestParam("input") String input){
        return manageService.manageShop(openid,page,input);
    }


    @ApiOperation("维护人员的设备")
    @PostMapping("/manage/manageDevice")
    public Result manageDevice(@RequestHeader("openid") String openid,
                             @RequestParam("page") Integer page,
                             @RequestParam("input") String input){
        return manageService.manageDevice(openid,page,input);
    }


    @ApiOperation("维护人员的维修列表")
    @PostMapping("/manage/manageRecord")
    public Result manageRecord(@RequestHeader("openid") String openid,
                               @RequestParam("page") Integer page,
                               @RequestParam("beginDate") String beginDate,
                               @RequestParam("endDate") String endDete,
                               @RequestParam("status") Integer status,
                               @RequestParam("type") String type){
        return manageService.manageRecord(openid,page,beginDate,endDete,status,type);
    }

    @ApiOperation("维护人员的校验设备")
    @PostMapping("/manage/verifyDevce")
    public Result verifyDevce(@RequestParam("sn") String sn){
        return manageService.verifyDevce(sn);
    }


    @ApiOperation("维护人员的修改维修记录状态")
    @PostMapping("/manage/repairDevice")
    public Result repairDevice(@RequestParam("id") Integer id,
                              @RequestParam("status") Integer status){
        return manageService.repairDevce(id,status);
    }


    @ApiOperation("维护人员的店铺列表")
    @PostMapping("/manage/shopList")
    public Result shopList(@RequestHeader("openid") String openid){
        return manageService.shopList(openid);
    }

    @ApiOperation("维护人员的创建店铺")
    @PostMapping("/manage/submitShop")
    public Result submitShop(@RequestHeader("openid") String openid,
                             @RequestParam("shopName") String shopName,
                             @RequestParam("tel") String tel,
                             @RequestParam("address") String address,
                             @RequestParam("commission") Integer commission,
                             @RequestParam("id") Integer id,
                             @RequestParam("latitude") String latitude,
                             @RequestParam("longitude") String longitude,
                             @RequestParam("name") String name){
        return manageService.submitShop(openid, shopName,tel,address,commission,id,name,latitude,longitude);
    }


    @ApiOperation("维护人员的收入统计")
    @PostMapping("/manage/incomeStatistics")
    public Result incomeStatistics(@RequestHeader("openid") String openid,
                                   @RequestParam("beginDate") String beginDate,
                                   @RequestParam("endDate") String endDate){
        return manageService.incomeStatistics(openid, beginDate,endDate);
    }


    @ApiOperation("维护人员的日订单数据")
    @PostMapping("/manage/orderStatistics")
    public Result orderStatistics(@RequestHeader("openid") String openid,
                                  @RequestParam("date")  String date){
        return manageService.orderStatistics(openid, date);
    }

    @ApiOperation("店铺的维修单")
    @PostMapping("/manage/faultRecord")
    public Result faultRecord(@RequestHeader("openid") String openid,
                                  @RequestParam("id")  Integer id,
                                  @RequestParam("status")  String status){
        return manageService.faultRecord(openid, id,status);
    }


    @ApiOperation("维护人员的收入统计")
    @PostMapping("/manage/income")
    public Result income(@RequestHeader("openid") String openid,
                              @RequestParam("page")  Integer page){
        return manageService.incomeStatistics(openid, page);
    }
}
